#ifndef YCCORELIVEMODEL_H
#define YCCORELIVEMODEL_H

#include "liveinfo.h"
#include "modeltype.h"
#include <QList>
#include <QObject>

namespace yc {

class LiveModel : public QObject
{
    Q_OBJECT
public:
    explicit LiveModel(QObject* parent = nullptr);
    ~LiveModel();

    const QList<LiveWebEntry>& webEntries() const { return web_entries_; }
    void setWebEntries(const QList<LiveWebEntry>& entries) { web_entries_ = entries; }
    LiveWebEntry webEntry(int platform) const;
    void addWebEntry(const LiveWebEntry& entry) { web_entries_.push_back(entry); }

    const QList<LiveInfo*>& lives() const { return lives_; }
    LiveInfo* live(int id) const;
    void add(const LiveInfo& li);
    void remove(int id);
    void clear();

    LiveInfo* activeLive(int presenter) const;
    LiveInfo* findLive(const QString& platform_id) const;
    void setLiveStatus(int id, int status, int view_count, int like_count,
                       const QDateTime& update_time, int updater);
    void setLiveStatus(LiveInfo* li, int status, int view_count, int like_count,
                       const QDateTime& update_time, int updater);

Q_SIGNALS:
    void added(yc::LiveInfo* li, QPrivateSignal);
    void changed(yc::LiveInfo* li, QPrivateSignal);
    void removed(yc::LiveInfo* li, QPrivateSignal);
    void modelAboutToBeReset(QPrivateSignal);
    void modelReset(QPrivateSignal);

private:
    QList<LiveWebEntry> web_entries_;
    QList<LiveInfo*> lives_;
};

} // namespace yc

#endif // YCCORELIVEMODEL_H
